<?php
// !DESC: This method simply erases any viddler data saved to the user's session. If a redirect argument is passed it will redirect the user otherwise simply return true.

// !LIBRARIES USED: session
// !HELPERS USED: url

// !VAR -> $redirect :: The path you want to redirect the user to (Defaults to NULL)

function viddler_logout($redirect=NULL)
{
	
	$__ci =& get_instance();
	$__ci->load->helper('url');
	$__ci->load->library("session");
	
	$__ci->session->unset_userdata(array(
		"viddler_username"		=>		"",
		"viddler_sessionid"		=>		"",
		"viddler_token"			=>		""
	));
	
	if (!is_null($redirect)) {
		redirect(base_url() . $redirect, "location");
	}
	else {
		return true;
	}
		
}
?>